from django.contrib.sitemaps import Sitemap
from django.urls import reverse

from blog.models import Article, Category, Tag


class StaticViewSitemap(Sitemap):
    priority = 0.5
    changefreq = 'daily'

    def items(self):
        return ['blog:index']

    def location(self, item):
        return reverse(item)


class AritcleSiteMap(Sitemap):
    priority = 0.6
    changefreq = 'Weekly'

    def items(self):
        return Article.objects.filter(status=0)

    def lastmod(self, obj):
        return obj.update_time


class CategorySiteMap(Sitemap):
    priority = 0.6
    changefreq = 'Weekly'

    def items(self):
        return Category.objects.all()

    def lastmod(self, obj):
        return obj.update_time


class TagSiteMap(Sitemap):
    changefreq = "Weekly"
    priority = "0.3"

    def items(self):
        return Tag.objects.all()

    def lastmod(self, obj):
        return obj.update_time



